package com.spring.learn.config;

import com.spring.learn.service.NoAnnoService;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by baiguantao on 2018/1/12.
 *
 * 验证bean的理解
 *
 *

 @Scope(BeanDefinition.SCOPE_PROTOTYPE)的情况

 我执行了吗？bean的范围
 com.spring.learn.service.UserService@4f3e6a71
 com.spring.learn.service.NoAnnoService@247665e2
 我执行了吗？bean的范围
 com.spring.learn.service.UserService@4f3e6a71
 com.spring.learn.service.NoAnnoService@7399e9ab


 @Scope(BeanDefinition.SCOPE_SINGLETON)的情况
 NoAnnoService实例是一个

 不设置@Scope默认是单例的。
 */

@Configuration
public class TestBeanAno {

    @Bean(autowire = Autowire.BY_NAME,name = "ricky")
//    @Scope(BeanDefinition.SCOPE_PROTOTYPE)
//    @Scope(BeanDefinition.SCOPE_SINGLETON)
    public NoAnnoService getNoAnnoService(){
        return  new NoAnnoService();
    }
}
